package com.example.alee.mybatis.springmybatis.mapper;

import com.example.alee.mybatis.springmybatis.po.ArticlePo;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ArticleDao {

    @Select("""
            select id,user_id,title,summary,read_count,create_time,update_time
            from article where user_id = #{userId}
                        """)
    @Results(id = "BaseArticleMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "user_id", property = "user_id"),
            @Result(column = "title", property = "title"),
            @Result(column = "summary", property = "summary"),
            @Result(column = "read_count", property = "read_count"),
            @Result(column = "create_time", property = "create_time"),
            @Result(column = "update_time", property = "update_time"),
    })
    List<ArticlePo> selectListArticle(Integer userId);


    @Select("""
            select * from article where id = #{article_Id}
            """)
    @ResultMap(value = "BaseArticleMap")
    ArticlePo selectById(Integer article_Id);


    @Select("""
            select * from article where id = #{article_Id}
            """)
    @ResultMap("ActionBaseMapper")
    ArticlePo selectMappersXmlById(Integer article_Id);


}
